<!DOCTYPE html>
<html>
<head>
	<title>Login</title>
	<meta charset="utf-8">
	<link href="css/style2.css" rel='stylesheet' type='text/css'/>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<script type="application/x-javascript"> addEventListener("load", function () {
		setTimeout(hideURLbar, 0);
	}, false);

	function hideURLbar() {
		window.scrollTo(0, 1);
	} </script>
</head>
<body>
<div class="main">
	<div class="login-form">
		<h1>用户注册</h1>
		<div class="head">
			<img src="images/user.png" alt=""/>
		</div>
		<form>
			<input type="text" class="text" name="userCode" value="账号" onfocus="this.value = '';"
				   onblur="if (this.value == '') {this.value = '账号';}">
			<input type="password" name="password" value="Password" onfocus="this.value = '';"
				   onblur="if (this.value == '') {this.value = 'Password';}">
			<div class="submit">
				<input type="button" onclick="myFunction()" value="注册">
			</div>
			<p><a href="#">忘记密码 ?</a></p>
		</form>
	</div>
</div>

<!--<div style="display:none"><script src='http://v7.cnzz.com/stat.php?id=155540&web_id=155540' language='JavaScript' charset='gb2312'></script></div>-->
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
	function myFunction() {
		console.log('请求')
		$.ajax({
			url: 'register',
			data: {
				"userCode": $('input[name=userCode]').val(),
				"password": $('input[name=password]').val()
			},
			method: 'post',
			success: res => {
				alert('注册成功')
				location.href='index.html'
			},
			error: res => {
				alert('注册错误')
			}
		})
	}
</script>
</body>
</html>
